<?php

namespace App\Modules\Device\Services;
use Illuminate\Support\Facades\DB;
use  App\Modules\Device\Models\Facory;



class FacoryService
{
    //厂家列表
    public static function getList($params){

        $obj = Facory::where('status','>=',1)->orderBy('id','desc');
        if(isset($params['brand_name']) && $params['brand_name']) {
            $obj->where('brand_name','like','%'.$params['brand_name'].'%');
        }
        if(isset($params['device_type']) && $params['device_type']) {
            $obj->where('device_type',$params['device_type']);
        }

        if(isset($params['id']) && $params['id']) {
            $obj->where('id',$params['id']);
        }

        return $obj->paginate();
    }

    public static function oneData($id){
        return Facory::where('id',$id)->first();
    }

    //添加厂家
    public static function addFacory($param){
        return Facory::addFacory($param);

    }

    //更新厂家
    public static function upFacory($id,$param){

        return Facory::upFacory($id,$param);

    }

    //删除
    public static function deleteFacory($id,$param){

        return Facory::upFacory($id,$param);
    }


    public static function band_list(){
        return Facory::select('id','brand_name')->where('status',1)->get();
    }
}